<?php

namespace IDock\Insurance\TAIC\Response;

use IDock\Http\Response;
use IDock\Printer\NonCar\NonCarProductListPrinter;
use IDock\Printer\NonCar\NonCarProductPrinter;
use IDock\Printer\NonCar\NonCarSubCoveragePrinter;

class NonCarProductListResponse extends AllTAICResponse
{

    public $seat = 5;

    public function printerInit(): Response
    {
        $printer = new NonCarProductListPrinter();

        $list = [
            [
                'productCode' => '1101',
                'productName' => '成都驾乘无忧(A四座)',
                'planCode' => 'FA025867',
                'planName' => '成都驾乘无忧(A四座)',
                'premium' => '160',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '800000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '800000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '72000',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '驾乘无忧A(5座228元)',
                'planCode' => 'FA025868',
                'planName' => '驾乘无忧A(5座228元)',
                'premium' => '228.00',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '1000000.00',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '1000000.00',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '自费医疗费用补偿保险',
                        'amount' => '100000.00',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '90000.00',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '驾乘无忧B(5座358元)',
                'planCode' => 'FA025871',
                'planName' => '驾乘无忧B(5座358元)',
                'premium' => '358',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '2000000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '2000000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '135000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '自费医疗费用补偿保险',
                        'amount' => '100000.00',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '成都驾乘无忧(C五座)',
                'planCode' => 'FA025873',
                'planName' => '成都驾乘无忧(C五座)',
                'premium' => '500',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '3000000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '3000000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '180000',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '成都驾乘无忧(D五座)',
                'planCode' => 'FA025875',
                'planName' => '成都驾乘无忧(D五座)',
                'premium' => '660',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '4000000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '4000000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '225000',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '成都驾乘无忧(A六座)',
                'planCode' => 'FA025869',
                'planName' => '成都驾乘无忧(A六座)',
                'premium' => '240',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '1200000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '1200000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '108000',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '驾乘无忧A(7座288元)',
                'planCode' => 'FA025870',
                'planName' => '驾乘无忧A(7座288元)',
                'premium' => '288.00',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '1400000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '1400000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '126000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '自费医疗费用补偿保险',
                        'amount' => '100000.00',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '驾乘无忧B(7座478元)',
                'planCode' => 'FA025872',
                'planName' => '驾乘无忧B(7座478元)',
                'premium' => '478.00',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '2800000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '2800000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '189000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '自费医疗费用补偿保险',
                        'amount' => '100000.00',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '成都驾乘无忧(C七座)',
                'planCode' => 'FA025874',
                'planName' => '成都驾乘无忧(C七座)',
                'premium' => '700',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '4200000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '4200000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '252000',
                        'premium' => '',
                    ],
                ],
            ], [
                'productCode' => '1101',
                'productName' => '成都驾乘无忧(D七座)',
                'planCode' => 'FA025876',
                'planName' => '成都驾乘无忧(D七座)',
                'premium' => '920',
                'maxLimit' => '1',
                'coverageList' => [
                    [
                        'subCode' => '0895001',
                        'subName' => '锦程交通意外伤害保险',
                        'amount' => '5600000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895002',
                        'subName' => '交通意外伤害医疗保险',
                        'amount' => '5600000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '0895003',
                        'subName' => '意外伤害住院医疗补助保险',
                        'amount' => '315000',
                        'premium' => '',
                    ],
                ],
            ],
        ];

        foreach ($list as $item) {
            $amount = 0;
            $productPrinter = new NonCarProductPrinter();
            $productPrinter->productCode = $item['productCode'] ?? '';//产品编码
            $productPrinter->productName = $item['productName'] ?? '';//产品名称
            $productPrinter->productType = '驾意险';
            $productPrinter->productDesc = '';
            $productPrinter->planCode = $item['planCode'] ?? '';//方案代码
            $productPrinter->planName = $item['planName'] ?? '';//方案名称
            $productPrinter->maxQuantity = $item['maxLimit'];//最大购买份数
            foreach ($item['coverageList'] ?? [] as $sub) {
                $subCoverage = new NonCarSubCoveragePrinter();
                $subCoverage->subCode = $sub['subCode'] ?? '';
                $subCoverage->subName = $sub['subName'] ?? '';
                $subCoverage->amount = $sub['amount'] ?? '';
                $amount += $subCoverage->amount;
                $productPrinter->subCoverageAppend($subCoverage);
            }
            $productPrinter->premium = $item['premium'];
            $productPrinter->unitAmount = $amount;
            $productPrinter->argc['amount'] = $amount;
            $productPrinter->argc['productName'] = $item['productName'] ?? '';//产品名称

            $printer->productListAppend($productPrinter);
        }

        $this->printer = $printer;
        return $this;
    }
}
